<template>
  <Fieldset legend="Overlay" :toggleable="true">
    <div class="mb-1 text-sm font-semibold text-surface-950 dark:text-surface-0">Select</div>
    <section class="grid grid-cols-4 mb-3 gap-2">
      <div class="flex flex-col gap-1">
        <DesignTokenField v-model="colorScheme.overlay.select.background" label="BG" type="color" />
      </div>
      <div class="flex flex-col gap-1">
        <DesignTokenField v-model="colorScheme.overlay.select.borderColor" label="Border Color" type="color" />
      </div>
      <div class="flex flex-col gap-1">
        <DesignTokenField v-model="colorScheme.overlay.select.color" label="Color" type="color" />
      </div>
      <div class="flex flex-col gap-1"></div>
    </section>

    <div class="mb-1 text-sm font-semibold text-surface-950 dark:text-surface-0">Popover</div>
    <section class="grid grid-cols-4 mb-3 gap-2">
      <div class="flex flex-col gap-1">
        <DesignTokenField v-model="colorScheme.overlay.popover.background" label="BG" type="color" />
      </div>
      <div class="flex flex-col gap-1">
        <DesignTokenField v-model="colorScheme.overlay.popover.borderColor" label="Border Color" type="color" />
      </div>
      <div class="flex flex-col gap-1">
        <DesignTokenField v-model="colorScheme.overlay.popover.color" label="Color" type="color" />
      </div>
      <div class="flex flex-col gap-1"></div>
    </section>

    <div class="mb-1 text-sm font-semibold text-surface-950 dark:text-surface-0">Modal</div>
    <section class="grid grid-cols-4 gap-2">
      <div class="flex flex-col gap-1">
        <DesignTokenField v-model="colorScheme.overlay.modal.background" label="BG" type="color" />
      </div>
      <div class="flex flex-col gap-1">
        <DesignTokenField v-model="colorScheme.overlay.modal.borderColor" label="Border Color" type="color" />
      </div>
      <div class="flex flex-col gap-1">
        <DesignTokenField v-model="colorScheme.overlay.modal.color" label="Color" type="color" />
      </div>
      <div class="flex flex-col gap-1"></div>
    </section>
  </Fieldset>
</template>

<script setup lang="ts">
  import { ref } from 'vue'
  import DesignTokenField from '../../base/DesignTokenField.vue'
  import { inject, type Ref } from 'vue'

  interface OverlayItem {
    background: string
    borderColor: string
    color: string
  }

  interface Overlay {
    select: OverlayItem
    popover: OverlayItem
    modal: OverlayItem
  }

  interface ColorScheme {
    overlay: Overlay
    value: any
  }

  const colorScheme = inject('$colorScheme') as Ref<ColorScheme>
</script>
